a11y: Add a hash function for cell infos
authorBenjamin Otte <otte@redhat.com>
Sat, 12 Nov 2011 04:38:52 +0000 (05:38 +0100)
committerBenjamin Otte <otte@redhat.com>
Wed, 16 Nov 2011 03:39:24 +0000 (04:39 +0100)
Note that comparing the tree is not necessary as the nodes are already
unique per row.

gtk/a11y/gtktreeviewaccessible.c

index 0680a946a9aa66eff1ef4d0feac3134455fe950e..ebab327e80f5f596fd59f5c4d98fed7fc0b4bcda 100644 (file)
@@ -241,6 +241,28 @@ cell_info_get_path (GtkTreeViewAccessibleCellInfo *cell_info)
                                    cell_info->node);
 }
 
+static guint
+cell_info_hash (gconstpointer info)
+{
+  const GtkTreeViewAccessibleCellInfo *cell_info = info;
+  guint node, col;
+
+  node = GPOINTER_TO_UINT (cell_info->node);
+  col = GPOINTER_TO_UINT (cell_info->cell_col_ref);
+
+  return ((node << sizeof (guint) / 2) | (node >> sizeof (guint) / 2)) ^ col;
+}
+
+static gboolean
+cell_info_equal (gconstpointer a, gconstpointer b)
+{
+  const GtkTreeViewAccessibleCellInfo *cell_info_a = a;
+  const GtkTreeViewAccessibleCellInfo *cell_info_b = b;
+
+  return cell_info_a->node == cell_info_b->node &&
+         cell_info_a->cell_col_ref == cell_info_b->cell_col_ref;
+}
+
 static void
 gtk_tree_view_accessible_initialize (AtkObject *obj,
                                      gpointer   data)
@@ -263,8 +285,8 @@ gtk_tree_view_accessible_initialize (AtkObject *obj,
   accessible->idle_expand_path = NULL;
   accessible->n_children_deleted = 0;
 
-  accessible->cell_infos = g_hash_table_new_full (g_direct_hash,
-      g_direct_equal, NULL, (GDestroyNotify) cell_info_free);
+  accessible->cell_infos = g_hash_table_new_full (cell_info_hash,
+      cell_info_equal, NULL, (GDestroyNotify) cell_info_free);
 
   widget = GTK_WIDGET (data);
   tree_view = GTK_TREE_VIEW (widget);